package cn.edu.nwpu.manager.service.impl;

import cn.edu.nwpu.manager.bean.Account;
import cn.edu.nwpu.manager.mapper.LoginMapper;
import cn.edu.nwpu.manager.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Hutengzhong
 * @version 1.0.0
 * @title LoginServiceImpl
 * @description TODO
 * @date 2023/9/16
 */
@Service
public class LoginServiceImpl implements LoginService {

    // 调用持久层
    @Autowired
    LoginMapper loginMapper;
    /**
     * 判断账号是否存在
     *
     * @param userAccount: 账号名
     * @return: 用户id
     */
    @Override
    public Integer checkAccount(String userAccount) {

        Integer id = loginMapper.getIdByAccount(userAccount);

        return id;
    }

    /**
     * 判断账号是否存在
     *
     * @param account: 账号 & 密码
     * @return: 用户id
     */
    @Override
    public Account chackPassword(Account account) {

        Account result = loginMapper.getIdByAccountAndPassword(account.getUserAccount(), account.getUserPassWord());

        return result;
    }

    /**
     * 做shrio认证
     * @param userName 用户登录名
     * @return
     */
    @Override
    public Account selectOneByUserName(String userName) {
        Account result = loginMapper.getAccountByuserName(userName);
        return result;
    }
}
